﻿#include "qstringex.h"
#include "../sys_h/SYS_VER.h"

QStringEx::QStringEx()
{
}

void QStringEx::toUtf8(char *str)
{
	if (!str)
		return ;
	QString   sdepict;  
	sdepict=QStringEx::fromLocal8Bit(str);
	sprintf(str,"%s",sdepict.toUtf8().data());
}

void QStringEx::fromUtf8(char *str)
{
	if (!str)
		return ;
	QString   sdepict;  
	sdepict=QString::fromUtf8(str);
	sprintf(str, "%s",sdepict.toLocal8Bit().data());
}

QString QStringEx::fromNetFileNameLocal8Bit(const char * str, int size)
{
#ifdef CUR_RUN_SYS_WINDOWS_VS2008
	return QString::fromUtf8(str,size);
#endif
#ifdef CUR_RUN_SYS_LINUX_QT
	return QString::fromUtf8(str,size);
#endif
	return QString::fromUtf8(str,size);
}

QString QStringEx::fromLocal8Bit(const char * str, int size)
{
#ifdef CUR_RUN_SYS_WINDOWS_VS2008
        return QString::fromLocal8Bit(str,size);
#endif
#ifdef CUR_RUN_SYS_LINUX_QT
        return QString::fromLocal8Bit(str,size);
#endif
	return QString::fromLocal8Bit(str,size);
}

QString QStringEx::fromDBString(const char * str, int size)
{
#ifdef CUR_RUN_SYS_WINDOWS_VS2008
        return QString::fromLocal8Bit(str,size);
#endif
#ifdef CUR_RUN_SYS_LINUX_QT
        return QString::fromLocal8Bit(str,size);
#endif
        return QString::fromLocal8Bit(str,size);
}

const char* QStringEx::dbStrToLocalconst(const char * str, int size)
{
#ifdef CUR_RUN_SYS_WINDOWS_VS2008
        return str;
#endif
#ifdef CUR_RUN_SYS_LINUX_QT
        return QString::fromLocal8Bit(str,size).toUtf8().constData();
#endif
        return str;
}

char* QStringEx::dbStrToLocal(const char * str, int size)
{
#ifdef CUR_RUN_SYS_WINDOWS_VS2008
        return (char*)str;
#endif
#ifdef CUR_RUN_SYS_LINUX_QT
        return (char*)str;
#endif
        return (char*)str;
}

